package io.github.talelin.latticy.execl.oms.Product;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import io.github.talelin.latticy.common.enumeration.ProductEnum;

/**
 * @ClassName：StatusConverter
 * @Author: ljj
 * @Date: 2022/5/11 16:39
 */
public class StatusConverter implements Converter<Integer> {

    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public WriteCellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (value.equals(ProductEnum.PENDING_REVIEW.getValue())) {
            return new WriteCellData(ProductEnum.PENDING_REVIEW.getDesc());
        } else if (value.equals(ProductEnum.AUDITED.getValue())) {
            return new WriteCellData(ProductEnum.AUDITED.getDesc());
        } else if (value.equals(ProductEnum.DELETE.getValue())) {
            return new WriteCellData(ProductEnum.DELETE.getDesc());
        } else {
            return new WriteCellData("UNKNOWN");
        }
    }
}
